import all_pages
import home_page
import theme
from AuthMiddleware import AuthMiddleware
from nicegui import app, ui
import pages.login

# from nicegui_toolkit import inject_layout_tool

# # 确保在创建任何 ui 组件之前调用,这样才能正常使用布局工具
# inject_layout_tool()

# 静态文件目录
app.add_static_files("/img", "img")
app.add_middleware(AuthMiddleware)


# here we use our custom page decorator directly and just put the content creation into a separate function
@ui.page("/")
def index_page() -> None:
    # 能进入进入主页，创建所有页面
    all_pages.create()
    with theme.frame("Homepage"):
        home_page.content()


if __name__ in {"__main__", "__mp_main__"}:
    ui.run(storage_secret="gcmc_nice_gui", title="NiceGUI测试")
